{***************************************************************
    SpyGestion  Copyright (C) 2008 Christophe KOALI <nature2gas@gmail.com>
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
****************************************************************}
unit uConfirmation;

interface

uses
  Windows, Messages, SysUtils,  Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, modRapport, modBaseType, ExtCtrls;

type
  TformConfirmation = class(TForm)
    lblInfos: TLabel;
    timHide: TTimer;
    procedure timHideTimer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure ShowAdv(Rapport: PRapportHead; r: integer);
    procedure ShowNotif(sMsg: string; iDelayAffichage: integer = 3500);
    procedure ShowNotifErreur(sMsg: string);
  end;

var
  formConfirmation: TformConfirmation;

implementation

{$R *.dfm}

procedure TformConfirmation.ShowNotifErreur(sMsg: string);
begin
    lblInfos.Caption := sMsg;

    timHide.Interval := 3500;

    lblInfos.Font.Color := clRed;

    Top := Screen.Height - Height - 100;
    Left := Screen.Width - Width - 30;
    Show;
    SetFocus;
end;

procedure TformConfirmation.ShowNotif(sMsg: string; iDelayAffichage: integer = 3500);
begin
    lblInfos.Caption := sMsg;

    timHide.Interval := iDelayAffichage;

    lblInfos.Font.Color := clBlue;

    Top := Screen.Height - Height - 100;
    Left := Screen.Width - Width - 30;
    Show;
    SetFocus;
end;

procedure TformConfirmation.ShowAdv(Rapport: PRapportHead; r: integer);
begin
    if Rapport <> nil then begin
       Caption := 'Confirmation - ' + mbtPlanetLocationToStr(Rapport.PlaneteLocation);
       lblInfos.Caption := mbtPlanetLocationToStr(Rapport.PlaneteLocation) + ' ok';
    end;

    timHide.Interval := 1500;

    Top := Screen.Height - Height - 100;
    Left := Screen.Width - Width - 30;

    if r = 1 then
       lblInfos.Font.Color := clBlack
    else
       lblInfos.Font.Color := clRed;
       

    Show;
    SetFocus;
end;


procedure TformConfirmation.timHideTimer(Sender: TObject);
begin
    if timHide.Interval > 0 then begin
       timHide.Interval := 0;
       Hide;
    end;

end;

end.
